<template>
	<view class="content">
		<view class="title" style="margin-top: 200rpx;">您的身高是？</view>
		
		<picker-view :indicator-style="indicatorStyle" :value="value" @change="bindChange"
			class="picker-view" mask-style="background:transparent;">
			<picker-view-column>
				<view class="item" :class="{ select: item == currentItem }" v-for="(item, index) in list" :key="index">
					{{ item.height + item.unit }}
				</view>
			</picker-view-column>
		</picker-view>
		
		<z-register-bottom @next='next'></z-register-bottom>
	</view>
</template>

<script>
import RouteUtil from '../../common/RouteUtil';
	export default {
		data() {
			return {
				data: {
					sex: '',
					nick: '',
					birthday: '',
					heightId: '',
					weightId: '',
					careerId: '',
					incomeId: '',
					tagIds:'',
					educId: '',
					headPicId: '',
					prId: '',
					cityId: '',
					distId: '',
					passWord:'123456'
				},
				list: [],
				currentItem: {},
				value: [0],
				indicatorStyle: `height: 50px;`,
			};
		},
		onLoad() {
			this.data = uni.getStorageSync('registerInfo');
			this.requestDict();
		},
		methods: {
			back(){
				uni.navigateBack();
			},
			async requestDict() {
				let res = await this.$common.get('/api/dict/detail');
				if (200 == res.code) {
					this.list = res.data.dictHeights;
					this.currentItem = this.list[this.value[0]];
					this.data.heightId = this.list[this.value[0]].id;
				}
			},
			bindChange: function(e) {
				const val = e.detail.value;
				this.currentItem = this.list[val[0]];
				this.data.heightId = this.list[val[0]].id;
			},
			async next() {
				uni.setStorageSync('registerInfo', this.data);
				RouteUtil.toRegister4()
			}
		}
	};
</script>

<style lang="scss">
	.content {
		width: 100wh;
		height: 100vh;
		margin: 0 50rpx;

		.title {
			font-weight: bold;
			font-size: 48rpx;
			color: #222;
		}

		.picker-view {
			width: 100%;
			height: 600rpx;
			margin: 0 auto;
		}
		
		.item {
			height: 50px;
			line-height: 50px;
			text-align: center;
			color: #999;
		}

		.item.select {
			color: #222;
			font-size: 36rpx;
			font-weight: 600;
		}
	}
</style>